package fr.efrei.abrousserajaspera.common.time;

import java.time.Duration;
import java.util.LinkedList;
import java.util.List;

import fr.efrei.abrousserajaspera.cloudPandemic.Ville;
import fr.efrei.abrousserajaspera.common.selection.SelectorIP;

public class Cure implements Event{
	private Ville ville;
	private List<Event> triggeredEventsList = new LinkedList<Event>();
	private Duration duration;
	private float rate;// rythm: 1s ou 3min ou...

	public Cure(float rate,Ville ville) {
		this.rate = rate;
		if(this.rate==1) this.duration = Duration.ofSeconds(10);
		else this.duration = Duration.ofSeconds(10).minusSeconds((long) this.rate);	
		this.ville = ville;
	}

	@Override
	public void trigger() {
		triggeredEventsList.add(this);
		ville.guerir(new SelectorIP().selectAmong(ville.getHabitants()));
	}

	@Override
	public Duration getBaseDuration() {
		return duration;
	}

	public void setRate(float rate) {		
		this.rate = rate;
	}

	@Override
	public double getRate() {
		return this.rate;
	}
}
